package com.yu.controller;

import com.yu.controller.dto.StuCount;
import com.yu.controller.dto.StuDateAnalysisModel;
import com.yu.service.StuScreenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
// TODO 数据可视化表现层接口
@RestController
@RequestMapping("/stuScreen")
public class StuScreenController {
    @Autowired
    StuScreenService stuScreenService;

    @GetMapping("/fname")
    public Result fnameSelect(int admissionyear,String academy) {
        List<StuDateAnalysisModel> stuFnames = stuScreenService.fnameSelect(admissionyear,academy);
        int code = stuFnames != null ? Code.GET_OK : Code.GET_ERR;
        return new Result(code,stuFnames);
    }
    @GetMapping("/age")
    public Result ageSelect(int admissionyear,String academy) {
        List<StuDateAnalysisModel> stuAges = stuScreenService.ageSelect(admissionyear,academy);
        int code = stuAges != null ? Code.GET_OK : Code.GET_ERR;
        return new Result(code,stuAges);
    }
    @GetMapping("/sex")
    public Result sexSelect(int admissionyear,String academy) {
        List<StuDateAnalysisModel> stuSexs = stuScreenService.sexSelect(admissionyear,academy);
        int code = stuSexs != null ?Code.GET_OK : Code.GET_ERR;
        return new Result(code,stuSexs);
    }
    @GetMapping("/major")
    public Result majorSelect(int admissionyear,String academy) {
        List<StuDateAnalysisModel> stuMajors = stuScreenService.majorSelect(admissionyear,academy);
        int code = stuMajors != null ? Code.GET_OK : Code.GET_ERR;
        return new Result(code,stuMajors);
    }
    @GetMapping("/stuAdmissionData")
    public Result stuAdmissionDataSelect(int admissionyear,String academy) {
        List<List<String>> stuAdmissionDatas = stuScreenService.stuAdmissionDataSelect(admissionyear,academy);
        int code = stuAdmissionDatas != null ? Code.GET_OK : Code.GET_ERR;
        return new Result(code,stuAdmissionDatas);
    }
    @GetMapping("/map")
    public Result stuMapSelect(int admissionyear,String academy) {
        List<StuDateAnalysisModel> stuMapDatas = stuScreenService.stuMapSelect(admissionyear,academy);
        int code = stuMapDatas!=null ? Code.GET_OK : Code.GET_ERR;
        return new Result(code,stuMapDatas);
    }
    @GetMapping("/stuCount")
    public Result stuCountSelect(int admissionyear,String academy) {
        StuCount stuCount = stuScreenService.stuCountSelect(admissionyear, academy);
        int code = stuCount!=null ? Code.GET_OK : Code.GET_ERR;
        return new Result(code,stuCount);
    }
}

